package day04;

import java.util.Scanner;

//进制转换
//StringBuilder的使用

//通过率：75
public class L0402 {
    public static void main (String[] args) {
        Scanner p=new Scanner (System.in);
        while(p.hasNextInt ()){
            int m=p.nextInt ();
            int n=p.nextInt ();
            System.out.println (Trans(m,n));
        }
    }
    public static String Trans(int m,int n){
        if(m==0)return "0";
        StringBuilder result=new StringBuilder ();
        while(m>0){
            int tem=m%n;
            char c;
            if(tem<10){
                c=(char)('0'+tem);
            }else{
                //大于10的数进行字母转换时，要减10，再加上字符A
                c=(char)('A'+(tem-10));
            }
            //append()方法直接加到尾部，insert()方法插入指定位置
            result.insert(0,c);
            m=m/n;
        }
        return result.toString ();
    }
}
